﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Obra.PowerShell.SmugMug
{
    internal class PathSegments
    {
        private readonly string path;
        private readonly List<string> segments = new List<string>();

        /// <summary>
        /// c-tor
        /// </summary>
        public PathSegments(
            string path)
        {
            this.path = path;

            segments.AddRange(path.Split(
                Obra.PowerShell.SmugMug.Path.PATH_SEPARATOR.ToCharArray(), 
                StringSplitOptions.RemoveEmptyEntries));
        }

        public int Count
        {
            get { return this.segments.Count; }
        }

        public string Path
        {
            get { return this.path; }
        }

        public string DriveName
        {
            get { return (this.segments.Count < 1) ? String.Empty : this.segments[0] + "\\"; }
        }

        public string AlbumName
        {
            get { return (this.segments.Count < 2) ? String.Empty : this.segments[1]; }
        }

        public string AlbumPath
        {
            //get { return Obra.PowerShell.SmugMug.Path.Combine(this.DriveName, this.AlbumName); }
            get { return System.IO.Path.Combine(this.DriveName, this.AlbumName); }
        }

        public string ImageName
        {
            get { return (this.segments.Count < 3) ? String.Empty : this.segments[2]; }
        }

        public string ImagePath
        {
            get { return Obra.PowerShell.SmugMug.Path.Combine(this.DriveName, this.AlbumName, this.ImageName); }
        }
    }
}
